package com.jlesbegu.arkanoid;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.View;

public class BricksTable {

	private List<Brick> bricks = new ArrayList<Brick>();



	public BricksTable(TableModel model, View view){
		for(int i=0 ; i<model.getTableMatrix().length ; i++){
			for(int j=0 ; j<model.getTableMatrix()[i].length ; j++){
				Bonus bonus = Bonus.NOTHING;
				if(model.getTableMatrix()[i][j] != ' '){
					char c = model.getTableMatrix()[i][j];
					switch(c){
					case('X'):
						bonus = Bonus.NOTHING;
					case('R'):
						bonus = Bonus.ENLARGE_RATEAU;
					break;
					case('r'):
						bonus = Bonus.DIMINISH_RATEAU;
					break;
					case('>'):
						bonus = Bonus.SPEED_UP;
					break;
					case('<'):
						bonus = Bonus.SPEED_DOWN;
					break;
					default: continue;
					}

					
					Bitmap bitbrick = BitmapFactory.decodeResource(view.getResources(), R.drawable.cubedecor);
					Bitmap bitmap = Bitmap.createScaledBitmap(bitbrick, Brick.DEFAULT_WIDTH, Brick.DEFAULT_HEIGHT, true);
					
					Brick brick = new Brick( j*Brick.DEFAULT_WIDTH, i*Brick.DEFAULT_HEIGHT,  bonus, view, bitmap);
							//i*Brick.DEFAULT_WIDTH,  j*Brick.DEFAULT_HEIGHT, bonus, view, bitmap);
					
					this.bricks.add(brick);
					

				}
			}

		}
	}



	public List<Brick> getBricks() {
		return bricks;
	}



	public void setBricks(List<Brick> bricks) {
		this.bricks = bricks;
	}
}
